package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentSaveDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
    * @Author: 丁伟伟
    * @Description: 评论--保存评论
    * @DateTime: 13:07 2023/6/28
    */
    @PostMapping("/save")
    public ResponseResult saveByDing(@RequestBody CommentSaveDto dto){
        return commentService.saveByDing(dto);
    }

    /**
    * @Author: 丁伟伟
    * @Description: 查询评论列表
    * @DateTime: 13:07 2023/6/28
    */
    @PostMapping("/load")
    public ResponseResult loadByDing(@RequestBody CommentDto dto){
        return commentService.loadByDing(dto);
    }

    /**
    * @Author: 丁伟伟
    * @Description: 点赞评论
    * @DateTime: 13:07 2023/6/28
    */
    @PostMapping("/like")
    public ResponseResult likeByDing(@RequestBody CommentLikeDto dto){
        return commentService.likeByDing(dto);
    }
}
